package com.example.cloudpracticeplatform.controller;

import com.example.cloudpracticeplatform.common.Response;
import com.example.cloudpracticeplatform.entity.Teacher;
import com.example.cloudpracticeplatform.service.TeacherService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/teacher")
@CrossOrigin
public class TeacherController {

    @Resource
    private TeacherService teacherService;

    @GetMapping("/{teacherId}")
    public Response<Teacher> getTeacherById(@PathVariable Integer teacherId) {
        Teacher teacher = teacherService.findById(teacherId);
        if (teacher != null) {
            return Response.success(teacher);
        } else {
            return Response.error("Teacher not found");
        }
    }
}